﻿'' GoogleCode - http://code.google.com/p/outlook-4-you/
'' GNU GPL v3 Licencing

Public Class frmComp
    Private Shared FormExists As Boolean = False
    Public Shared ReadOnly Property InstanceExists() As Boolean
        Get
            Return frmComp.FormExists
        End Get
    End Property
    Private component As String
    Private release As String
    Public root As String = "\\Man-01672\build"
    Public rel163 As String = root & "\rel163.csv"
    Public rel170 As String = root & "\rel170.csv"
    Public rel171 As String = root & "\rel171.csv"
    Public rel172 As String = root & "\rel172.csv"
    Public rel180 As String = root & "\rel180.csv"

    Public Sub New(ByVal comp As String, ByVal rel As String)
        ' This call is required by the Windows Form Designer.
        InitializeComponent()
        FormExists = True
        component = comp
        Me.Text = "What does " & comp & " build?"
        release = rel
        ' Add any initialization after the InitializeComponent() call.
    End Sub
    Private Function Read_2D(ByVal path As String, ByVal cnt As Integer) As String()()
        Dim csv As New CSV(path)
        Return csv.Read(cnt)
    End Function ' Puts sourcefile catalogue into array
    Private Function Write_2D() As Boolean
        Dim central_housing As String = ""
        Select Case release
            Case "16.3"
                central_housing = rel163
            Case "17.0"
                central_housing = rel170
            Case "17.1"
                central_housing = rel171
            Case "17.2"
                central_housing = rel172
            Case "18.0"
                central_housing = rel180
            Case "18.1"
                'central_housing = rel181
        End Select
        Dim csv As New CSV(central_housing)
        If csv.Write(central_housing) = True Then
            Return True
        End If
        Return False
    End Function
    Private Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        For i = 0 To frmRequest.catalogue.Length - 1
            If frmRequest.catalogue(i)(0).Contains(component) = True Then
                If txtComp.Text.ToString <> "" And txtType.Text.ToString <> "" Then
                    frmRequest.catalogue(i)(2) = txtComp.Text.ToString
                    frmRequest.catalogue(i)(3) = txtType.Text.ToString
                Else
                    MsgBox("Fill in the textboxes please")
                    Exit Sub
                End If
            End If
        Next
        If Write_2D() = True Then
            MsgBox("Thanks for helping")
        End If
        Me.DialogResult = Windows.Forms.DialogResult.OK
        Me.Dispose()
    End Sub


End Class